package lichtruong.bk.cse;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.os.AsyncTask;

public class UpDateDataToServer extends Activity {

	static double latitude, longitude;

	// report to blue road
	String ID_REPORT, MAIL_REPORT, TYPEREPORT;

	// Report to blue road
	// =================================================================== OK
	public void reportToBlueRoad(String id, String mail, String typereport) {
		ID_REPORT = id;
		MAIL_REPORT = mail;
		TYPEREPORT = typereport;
		new UpdateReport().execute();
	}
	class UpdateReport extends AsyncTask<String, String, String> {
		// get data
		JSONParser JsonParser = new JSONParser();
		private static final String URL_GETINFO = "http://lichcse.hol.es/report.php";

		@Override
		protected String doInBackground(String... args) {
			int success;
			try {
				List<NameValuePair> params = new ArrayList<NameValuePair>();
				params.add(new BasicNameValuePair("id", ID_REPORT));
				params.add(new BasicNameValuePair("mail", MAIL_REPORT));
				params.add(new BasicNameValuePair("treport", TYPEREPORT));
				JSONObject json = JsonParser.makeHttpRequest(URL_GETINFO,
						"POST", params);

				success = json.getInt("success");
				if (success == 1) {

				} else {

				}
			} catch (JSONException e) {
				e.printStackTrace();
			}
			return null;
		}

	}

	// end update data report to server
	// ==============================================================
}
